import React, { Component } from 'react'
import { SafeAreaView, Button } from 'react-native'
import { setUserInfo } from './utils/UserBean'
import { showToast } from 'rn-xiaobu-utils'
import NavigationService from './utils/NavigationService'

export default class Home extends Component {
  render () {
    return (
      <SafeAreaView>
        <Button title="公交测试" onPress={() => this._goToNextPage('Bus')}></Button>
        <Button title="云卡测试" onPress={() => this._goToNextPage('Card')}></Button>
        <Button title="订单列表测试" onPress={() => this._goToNextPage('Mall')}></Button>
        <Button title="订单Order测试" onPress={() => this._goToNextPage('Order')}></Button>
        <Button title="登录测试" onPress={() => this.props.navigation.push('Login')}></Button>
        <Button title="Home测试" onPress={() => NavigationService.push('Home')}></Button>
        <Button title="退出登录" onPress={() => this._loginout()}></Button>
      </SafeAreaView>

    )
  }

  _loginout = async () => {
    await setUserInfo({})
    showToast('退出成功')
  }

  _goToNextPage = (pageName) => {
    // let userInfo =
    // getUserInfo().then(userInfo => {
    //   if (userInfo && userInfo.IS_LOGIN) {
    //     this.props.navigation.push(pageName)
    //   } else {
    //     this.props.navigation.push('Login')
    //   }
    // })

    // this.props.navigation.push(pageName)
    NavigationService.push(pageName)
  }
}